package com.lxyk.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lxyk.pojo.WaterDetails;
import com.lxyk.service.WaterDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @ClassName WaterDetailsController
 * @Description TODO
 * @Author FJQ
 * @Date 2022/10/26 16:26
 * @Version 1.0
 **/
@RequestMapping("/stat")
@Controller
public class WaterDetailsController {

    @Autowired
    private WaterDetailsService waterDetailsService;

    @RequestMapping("/statWaterDetails")
    public String statWaterDetails(@RequestParam(required = false,defaultValue = "1",value = "pageNum") Integer pageNum,
                                   @RequestParam(defaultValue = "10",value = "pageSize") Integer pageSize,Model model,WaterDetails waterDetails){
        if (pageNum < 0 || pageNum.equals("") || pageNum == null){
            pageNum = 1;
        }
        if (pageSize < 0 || pageSize.equals("") || pageSize == null){
            pageSize = 10;
        }
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<WaterDetails> pageInfo = waterDetailsService.querySendWaterDetails(waterDetails,pageNum, pageSize);
        model.addAttribute("pageInfo",pageInfo);
        return "waterDetailsList";
    }

}
